﻿package com.wongoing.sys.service.impl;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wongoing.base.BaseServiceImpl;
import com.wongoing.sys.dao.SysTranslateDao;
import com.wongoing.sys.model.SysTranslate;
import com.wongoing.sys.service.SysTranslateService;

@Service("sysTranslateService")
public class SysTranslateServiceImpl extends BaseServiceImpl<SysTranslate> implements SysTranslateService {
	private SysTranslateDao dao;

	@Autowired
	public void setDao(SysTranslateDao dao) {
		super.setDao(dao);
		this.dao = dao;
	}
	
	/**
	 * 功能说明：根据关键词及系统使用语言获取对应消息
	 * 修改说明：
	 * @author zhenglibing
	 * @date 2017年10月13日 下午11:09:32
	 * @param usedLanguage 查询参数：使用的语言，zh or en
	 * @param keyString 查询参数：关键词
	 * @return
	 * @throws NoSuchMethodException 
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 */
	 public String getTranslateString(String usedLanguage,String keyString) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
		 String result = "";
		Map<String,Object> param = new HashMap<String, Object>();
		param.put("keyString", keyString);
		List<SysTranslate> translateList;
		translateList = this.dao.getByParam(param);
		if(translateList.size() > 0){
			if("zh".equals(usedLanguage)){
				result = translateList.get(0).getZhValue();
			}else{
				result = translateList.get(0).getEnValue();
			}
		}
		return result;
	 }
}
